<h2><?=tr('Users administration')?></h2>
<?php

	if (!is_null($form)) {

		echo $form->output();
		
	} else {

		$users = fgsUsers::get();

		if (!$users)
			echo tr('No users yet');
		else {
			$tbl = new htmlTable();

			$tbl->setHeader('action', array(
				'width' => '50px',
			));
			$tbl->setHeader('id', array(
				'title' => tr('Id'),
				'width' => '5ex',
			));
			$tbl->setHeader('login', array(
				'title' => tr('Login'),
				'width' => '15ex',
			));
			$tbl->setHeader('email', array(
				'title' => tr('Email'),
			));
			$tbl->setHeader('website', array(
				'title' => tr('Website'),
			));
			$tbl->setHeader('admin', array(
				'title' => tr('Adm.'),
				'width' => '6ex',
			));

			foreach ($users as $n) {
				$tbl->set('id', $n['id']);
				$tbl->set('login', $n['login']);
				$tbl->set('email', $n['email']);
				$tbl->set('website', sprintf('<a href="%s">%s</a>', $n['website'], $n['website']));
				$tbl->set('admin', $n['is_admin'] ? fgsBase::image('mark') : '');

				$actions = array();
				if ($n['is_deleted']) {
					$actions[] = fgsBase::linkPage(fgsBase::image('ok'), 'admin_players', array('show', $n['id']));
					$tbl->setLineParam('class', 'disabled');
				} else {
					$actions[] = fgsBase::linkPage(fgsBase::image('del'), 'admin_players', array('hide', $n['id']));
				}
				$actions[] = fgsBase::linkPage(fgsBase::image('edit'), 'admin_players', array('edit', $n['id']));

				$tbl->set('action', implode(' ', $actions));
					
				$tbl->push();
			}

			echo $tbl->render();
		}	

	}
	
?>
